package com.travelparadise.tests;

import java.util.Collection;
import java.util.List;

import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;

import com.travelparadise.dao.HotelDao;
import com.travelparadise.domain.Hotel;
import com.travelparadise.domain.Ville;


public class TestHotelDao extends TestCase{
	
	private HotelDao hotelDao=null;

	@Override
	protected void setUp() throws Exception {
		ApplicationContext springContext = SpringContextForTest.getSpringContext();
		this.hotelDao = (HotelDao) springContext.getBean("hotelDaoHibernate");
	}
	public void testGetById(){
		Hotel hotel =hotelDao.getById(1);
		assertTrue(hotel.getId()==1);
		System.out.println(hotel.toString());
		System.out.println("*****************************************");
	}
	public void testSearchByName(){
		Collection<Hotel> hotels= (List<Hotel>)hotelDao.searchByName("Eden");
		assertTrue(hotels.size()==8);
		for(Hotel hotel : hotels){
			System.out.println(hotel.toString());
		}
		System.out.println("*****************************************");
	}
	public void testSearchByVille(){
		Ville ville=new Ville();
		ville.setId(1);
		Collection<Hotel> hotels=(List<Hotel>)hotelDao.searchByVille(ville);
		assertTrue(hotels.size()==2);
		for(Hotel hotel : hotels){
			System.out.println(hotel.toString());
		}		
		System.out.println("*****************************************");
	}
}
